import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, main
from util import *

class ScrollLight(sim.Scroll):
    def __init__(self):
        sim.Scroll.__init__(self, "light", "?", colors['Yellow'])

    def read(self, reader):
        parole.debug('******** HELLO ************')
        self.map = reader.parentTile.map
        rgb = random.choice(['White', 'PaleTurquoise', 'Cyan', 'Pink',
            'SpringGreen', 'Teal'])
        self.lightSource = parole.map.LightSource(colors[rgb], 8.0)

        self.lightSource.apply(self.map, reader.pos)
        self.map.update()

        if main.mapFrame.fovObj and not main.player.dead:
            main.mapFrame.touchFOV()

#        main.schedule.add(sim.Event('stoplight', main.schedule.time + 2*60000,
#            (self,), dests=[self]))

#    def listen(self, event):
#        sim.Scroll.listen(self, event)
#
#        if event.id == 'unilluminate' and event.args[0] is self:
#            self.map.setAmbientLight((255,255,255), self.originalIntensity)
#            self.map.update()


#========================================
thingClass = ScrollLight
